﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GoodMan.Infrastructure.Entities.Repository;

namespace GoodMan.Infrastructure.Entities.Entity
{
    public class RebateReport : IAccessible<T_RebateReport, RebateReport>, ILogicEntity<T_RebateReport, RebateReport>
    {
        public int Id { get; set; }

        public string Year { get; set; }

        public string Month { get; set; }

        public int DormitoryId { get; set; }

        public string UserName { get; set; }

        public int DealOrders { get; set; }

        public int SuccessOrders { get; set; }

        public int CancelOrders { get; set; }

        public decimal SuccessMoney { get; set; }

        public decimal Rebate { get; set; }

        public decimal Bonus { get; set; }

        public DateTime CreateDate { get; set; }

        public string CreateUser { get; set; }

        public User user { get; set; }

        public RebateReport LoadUser(T_User User)
        {
            this.user = new User().Set(User);
            return this;
        }

        public Dormitory dormitory { get; set; }

        public RebateReport LoadDormitory(T_Dormitory dormitory)
        {
            this.dormitory = new Dormitory().Set(dormitory);
            return this;
        }

        protected override void Covariant(T_RebateReport model)
        {
            if (model != null)
            {
                this.Id = model.Id;
                this.Year = model.Year;
                this.Month = model.Month;
                this.DormitoryId = model.DormitoryId;
                this.UserName = model.UserName;
                this.DealOrders = model.DealOrders;
                this.SuccessOrders = model.SuccessOrders;
                this.CancelOrders = model.CancelOrders;
                this.SuccessMoney = model.SuccessMoney;
                this.Rebate = model.Rebate;
                this.Bonus = model.Bonus;
                this.CreateDate = model.CreateDate;
                this.CreateUser = model.CreateUser;
            }
        }

        protected override T_RebateReport Inverter(RebateReport model)
        {
            if (model != null)
            {
                return new T_RebateReport()
                {
                    Id = model.Id,
                    Year = model.Year,
                    Month = model.Month,
                    DormitoryId = model.DormitoryId,
                    UserName = model.UserName,
                    DealOrders = model.DealOrders,
                    SuccessOrders = model.SuccessOrders,
                    CancelOrders = model.CancelOrders,
                    SuccessMoney = model.SuccessMoney,
                    Rebate = model.Rebate,
                    Bonus = model.Bonus,
                    CreateDate = model.CreateDate,
                    CreateUser = model.CreateUser
                };
            }
            return null;
        }

        public RebateReport Set(T_RebateReport dbModel)
        {
            Covariant(dbModel);
            return this;
        }
    }
}
